home *** CD-ROM | disk | FTP | other *** search
/ Ian & Stuart's Australian Mac 1 / Ian and Stuart's One (Australia).iso / Australasian Legends / Commercial / Rainbow Hill / MacDOS™ 2.0.0 / batches / trashdir.bat < prev    next >
DOS Batch File  |  1994-06-30  |  1KB  |  52 lines

  1. @echo off
  2. !  trashdir.bat    Batch file to move a folder to the system Trash
  3. !
  4. !  trashdir name
  5. !
  6. !  where 'name' is the folder to be trashed. The name can be preceded by
  7. !  a path and a volume ID.
  8. !
  9. !  trashdir.bat calls extractName, uniqueName, copydir, and deldir
  10. !
  11. !  Copyright © 1994 by Rainbow Hill Pty Ltd. All rights reserved.
  12. !
  13.  
  14.     set trashdir_trash=1:\Trash
  15.  
  16.     ! ensure that the first parameter is there and that the second one is not
  17.     set doserr=13
  18.     if not "%2 " == " " goto ERR_LBL
  19.     if "%1 " == " " goto ERR_LBL
  20.  
  21.     ! ensure that the requested folder is there
  22.     set doserr=27
  23.     if not existdir "%1" goto ERR_LBL
  24.  
  25.     ! make a name to be used in the trash
  26.     set doserr=0
  27.     onerror ERR_LBL
  28.     call extractName "%1" trashdir_name
  29.     if not %doserr% == 0 goto ERR_LBL
  30.     call uniqueName "%trashdir_trash%\%trashdir_name%" trashdir_newName
  31.     if not %doserr% == 0 goto ERR_LBL
  32.  
  33.     ! if necessary, rename the copy already in the trash
  34.     if "%trashdir_name%" == "%trashdir_newName%" goto DO_COPY_LBL
  35.     rendir "%trashdir_trash%\%trashdir_name%" "%trashdir_newName%"
  36. :DO_COPY_LBL
  37.  
  38.     ! copy the folder to the trash and remove the original
  39.     call copydir "%1" "%trashdir_trash%"
  40.     if not %doserr% == 0 goto ERR_LBL
  41.     call deldir "%1"
  42.     if %doserr% == 0 goto DONE_LBL
  43.  
  44. :ERR_LBL
  45.     show %doserr%
  46.  
  47. :DONE_LBL
  48.     ! remove the global variables
  49.     set trashdir_name=
  50.     set trashdir_newName=
  51.     set trashdir_trash=
  52.